<?php
// *************************************************
// Produced by Sneekes.net
// All scripts are copyright Sneekes.net 1999 - 2006
// Visit the Sneekes.net site at http://sneekes.net
// or email us at peet@sneekes.net
// *************************************************
define('THIS_PROJECT_ROOT', '..');
require_once(THIS_PROJECT_ROOT . '/config.inc.php');

// if you want caching flip caching to 1
$smarty->caching = 0;
$smarty->compile_check = true;  

if(!$smarty->is_cached('index.tpl')) {
	if ( JAIKU_BASE_URL ) {
		$snoopy = new Snoopy();
		$snoopy->temp_dir = THIS_PROJECT_ROOT . '/cache/snoopy/';
		
		if ($snoopy->fetch(JAIKU_BASE_URL.'/feed/json/')) {
			$result = $snoopy->results;
			//print_r($result);
			$posts = json_decode($result);
			$smarty->assign('posts', $posts );
		} else {
			$smarty->assign('error', ''.$snoopy->error );
		
		}
	} else {
		$smarty->assign( 'error', 'define a good JSON_URL in config.inc.php' );
	}
	
	// Some personal settings
	$smarty->assign('page_title', 'json aggregation publication');
	$smarty->assign('sub_title', 'What did I do lately?');
	$smarty->assign('your_name', 'Jason Aggrigator');
	$smarty->assign('copyrights', 'Attribution-NonCommercial-NoDerivs 3.0 Unported');
	$smarty->assign('jaiku_base_url', JAIKU_BASE_URL);
	
}
$smarty->cache_lifetime = 600;
$smarty->display('index.tpl');
?>
